package org.eclipse.nebula.snippets.ganttchart;


import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;

import org.eclipse.nebula.widgets.ganttchart.GanttEvent;
import org.eclipse.nebula.widgets.ganttchart.IGanttEventListener;
import org.eclipse.swt.events.MouseEvent;

final class GanttEventListener implements
		IGanttEventListener {
	
	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
	
	public void eventDoubleClicked(GanttEvent event, MouseEvent me) {
		System.out.println("Event double clicked " + event);
	}

	public void eventPropertiesSelected(GanttEvent event) {
		System.out.println("Event properties selected " + event);
		event.setHeight(event.getHeight() + 10);
	}

	public void eventsDeleteRequest(ArrayList events, MouseEvent me) {
		System.out.println("Events delete request");
	}

	public void eventSelected(GanttEvent event, ArrayList allSelectedEvents, MouseEvent me) {
		System.out.println("Events selected");
	}

	public void eventsMoved(ArrayList events, MouseEvent me) {
		System.out.println("Events moved");
	}

	public void eventsResized(ArrayList events, MouseEvent me) {
		System.out.println("Events resized");
		
		for (Iterator iterator = events.iterator(); iterator.hasNext();) {
			GanttEvent event = (GanttEvent) iterator.next();
			System.out.println(event.getName());
			System.out.println("start:" + dateFormat.format(event.getStartDate().getTime()));
			System.out.println("end:" + dateFormat.format(event.getEndDate().getTime()));
		}
	}

	public void zoomedIn(int newZoomLevel) {
		System.out.println("Zoomed in to " + newZoomLevel);
	}

	public void zoomedOut(int newZoomLevel) {
		System.out.println("Zoomed out to " + newZoomLevel);
	}

	public void zoomReset() {
		System.out.println("Zoom level reset");
	}
}